<?php

/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2017/6/7
 * Time: 下午5:15
 */
class A
{

    public $t;

    public function __construct($t = "hello,world")
    {
        $this->t = $t;
    }

    function test()
    {
        call_user_func(function () {
            echo $this->t.PHP_EOL;
        });
    }


}

class Controller
{

    //调用具体的action，
    public function __act($action)
    {
//        call_user_func(
//            array($this, $action)
//        );
        $this->{$action}();
    }

}

class HelloController extends Controller
{

    public function index()
    {
        echo __METHOD__ . PHP_EOL;
    }

    public function hello()
    {
        echo __METHOD__ . PHP_EOL;
    }

    public function dance()
    {
        echo __METHOD__ . PHP_EOL;
    }

}


$a = new A();
$a->test();

$controller = new HelloController();
$controller->__act("index");

